<?php

namespace app\adminapi\export;

use app\services\agent\AgentManageServices;

class AgentActionListExport extends BaseExport
{
    protected $header = [
        '分销员', '新增销售额(元)', '新增客户数', '新增邀请数', '商品分享次数', '商品分享引流', '商品分享浏览量'
    ];

    public function createData(array $where)
    {
        $time =$where['time'] ?? [];
        $agent_nickname = $where['agent_nickname'] ?? '';
        $order_value = $where['order_value'] ?? 0;
        $order_type = $where['order_type'] ?? 0;
        $limit = $where['limit'] ?? 15;

        $list = app()->make(AgentManageServices::class)->actionList($time, $agent_nickname, $order_value, $order_type, $limit)['list'];

        $data = [];

        foreach ($list as $item) {

            $data[] = [
                $item['user']['nickname'] ?? '',
                $item['total_sale_count'] ?? '',
                $item['total_register_nums'] ?? '',
                $item['total_invitee_nums'] ?? '',
                $item['total_share_nums'] ?? '',
                $item['total_product_share_join_nums'] ?? '',
                $item['total_product_share_view_nums'] ?? '',
            ];
        }
        return $data;
    }
}